/*
 * bank.cc
 *
 *  Created on: Sep 24, 2012
 *      Author: shaohong
 */

#include "bank.hh"
#include <iostream>

using namespace std;

BankAccount::BankAccount(string const& owner, string const& accountNumber,
		double balance) {
	this->owner = owner;
	this->accountNumber = accountNumber;
	this->balance = balance;

}

string BankAccount::getOwner() const {
	return this->owner;
}


string BankAccount::getNumber() const {
	return this->accountNumber;
}


double BankAccount::getBalance() const {
	return this->balance;
}

void BankAccount::deposit(double amount) {
	this->balance += amount;
}

bool BankAccount::withdraw(double amount) {
	if (amount >= this->balance) {
		return false;
	}

	this->balance -= amount;

	return true;
}
void BankAccount::print() {
	cout << "Account num: " << getNumber() <<", owned by: " << getOwner()
			<<", balance: " << getBalance() << " eur" << endl;
}


bool transfer(BankAccount& src, BankAccount& dest, double amount) {
	if (src.getBalance() >= amount) {
		src.withdraw(amount);
		dest.deposit(amount);
		return true;
	} else {
		return false;
	}
}

